package com.yupi.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

import java.io.File;
import java.math.BigInteger;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.util.concurrent.Callable;

/**
 * @File: ASCIIArt
 * @Brief: Picocli 命令行示例代码
 * @Details:
 * @Author: Kevin
 * @Date: 2024/12/29 15:09
 * @Version: 1.0
 */

// 标记该类并为其命名
@Command(name = "ASCIIArt", mixinStandardHelpOptions = true, version = "ASCIIArt 1.0")
class ASCIIArt implements Runnable {

    // 解析选项
    @Option(names = { "-s", "--font-size" }, description = "Font size")
    int fontSize = 19;

    // 解析参数
    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli",
    description = "Words to be translated into ASCII art.")
    private String[] words = { "Hello", "picocli" };

    // 将字段设置为命令行参数，可以指定默认值，描述等信息
    @Override
    public void run() {
        // 自行实现业务逻辑
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    // requests for usage help or version help can be done with one line of code.
    public static void main(String... args) {
        // execute 能用于处理用户输入的命令，返回一个退出代码
        int exitCode = new CommandLine(new ASCIIArt()).execute(args);
        System.exit(exitCode);
    }
}
